﻿using Newtonsoft.Json;
using Quartz;
using System;
using System.Collections.Generic;
using System.Text;
using T.FAS.Runtime.ScheduleJob.Engine;
using T.FAS.Runtime.ScheduleJob.SPI;

namespace T.FAS.Runtime.ScheduleJob.Service
{
    public class ScheduleJobDetailBuilder
    {
        public IJobDetail BuildDetail (ScheduleJobExecContext context)
        {
            //创建作业
            var jobDetail = JobBuilder.Create<BasicScheduleJobExcutor>()
                .SetJobData(new JobDataMap() { { ScheduleJobRTPConst.DefaultJobContextDataKey, JsonConvert.SerializeObject(context) } })
                .StoreDurably(context.ScheduleJobMetaData.IsPersistent ? true : false)
                .WithIdentity(context.JobKey)
                .Build();
            return jobDetail;
        }
    }
}
